package com.cib.process.chat.core.handler.impl;

import com.cib.process.bean.CheckType;
import com.cib.process.bean.ServiceResult;
import com.cib.process.chat.bean.Completekey;
import com.cib.process.chat.bean.NumericLetterResult;
import com.cib.process.chat.bean.PlayType;
import com.cib.process.chat.bean.QueryResult;
import com.cib.process.chat.core.handler.ActionHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

/**
 * CVV2处理
 */
@Service
public class CvvActionHandler implements ActionHandler {
    @Value("${action.1001.result.minkey:3}")
    private String minkey;
    @Value("${action.1001.result.maxkey:3}")
    private String maxkey;
    @Value("${action.1001.result.numberflag:N}")
    private String numberflag;
    @Value("${action.1001.result.canbreak:N}")
    private String canbreak;
    @Value("${action.1001.result.recordflag:N}")
    private CheckType recordflag;
    @Value("${action.1001.result.poundflag:Y}")
    private String poundflag;

    @Autowired
    RedisTemplate<String,String> redisTemplate;

    @Override
    public ServiceResult execute(QueryResult queryResult) {
        NumericLetterResult result=new NumericLetterResult();
        result.setCompletekey(Completekey.NUM.getCode());       //输入结束键
        result.setContext(queryResult.getSuggestAnswer());      //话术
        result.setMaxkey(maxkey);               //最大输入位数
        result.setMinkey(minkey);           //最小输入位数
        result.setNumberflag(numberflag);   //是否全数字输入
        result.setType(PlayType.TTS);       //类型
        result.setCanbreak(canbreak);       //播报时是否可以打断
        result.setPoundflag(poundflag);     //是否允许代收#号键
        result.setRecordflag(recordflag);   //是否录音

        //CVV2需要屏蔽
        result.setMessageflag("Y");
        return ServiceResult.buildSuccessResult(result,queryResult.getSessionId(),queryResult.getAction());
    }
}
